// 购物网站常量定义

// 订单状态映射
export const ORDER_STATUS_MAP = {
  pending_payment: '待付款',
  pending_shipment: '待发货',
  shipped: '已发货',
  delivered: '已收货',
  completed: '已完成',
  cancelled: '已取消',
  refunding: '退款中',
  refunded: '已退款',
} as const

// 订单状态颜色映射
export const ORDER_STATUS_COLOR_MAP = {
  pending_payment: '#ff4142',
  pending_shipment: '#ff8800',
  shipped: '#4dabf7',
  delivered: '#00d100',
  completed: '#999999',
  cancelled: '#999999',
  refunding: '#ff4142',
  refunded: '#999999',
} as const

// 商品状态映射
export const PRODUCT_STATUS_MAP = {
  active: '上架中',
  inactive: '已下架',
  out_of_stock: '缺货',
} as const

// 用户状态映射
export const USER_STATUS_MAP = {
  active: '正常',
  inactive: '未激活',
  banned: '已封禁',
} as const

// 优惠券类型映射
export const COUPON_TYPE_MAP = {
  fixed: '满减券',
  percent: '折扣券',
  shipping: '包邮券',
} as const

// 性别映射
export const GENDER_MAP = {
  male: '男',
  female: '女',
  unknown: '未知',
} as const

// 排序选项
export const SORT_OPTIONS = [
  { label: '综合排序', value: 'created', order: 'desc' },
  { label: '价格从低到高', value: 'price', order: 'asc' },
  { label: '价格从高到低', value: 'price', order: 'desc' },
  { label: '销量从高到低', value: 'sales', order: 'desc' },
  { label: '评分从高到低', value: 'rating', order: 'desc' },
] as const

// 商品分类图标映射
export const CATEGORY_ICON_MAP: Record<string, string> = {
  'electronics': 'phone',
  'clothing': 'shirt',
  'home': 'home',
  'sports': 'basketball',
  'beauty': 'star',
  'books': 'book',
  'food': 'coffee',
  'toys': 'gift',
}

// 分页配置
export const PAGE_SIZES = [10, 20, 50, 100] as const
export const DEFAULT_PAGE_SIZE = 20

// 购物车最大商品数量
export const MAX_CART_QUANTITY = 99

// 商品图片占位符
export const PRODUCT_IMAGE_PLACEHOLDER = 'https://via.placeholder.com/300x300?text=商品图片'

// 用户头像占位符
export const USER_AVATAR_PLACEHOLDER = 'https://via.placeholder.com/100x100?text=头像'

// 评分星级配置
export const RATING_CONFIG = {
  max: 5,
  step: 0.5,
  colors: ['#dcdee0', '#ffc107'],
} as const

// 配送方式
export const SHIPPING_METHODS = [
  { id: 'standard', name: '标准配送', desc: '5-7个工作日', fee: 10 },
  { id: 'express', name: '加急配送', desc: '1-3个工作日', fee: 20 },
  { id: 'same_day', name: '当日达', desc: '24小时内送达', fee: 30 },
] as const

// 支付方式
export const PAYMENT_METHODS = [
  { id: 'wechat', name: '微信支付', icon: 'wechat' },
  { id: 'alipay', name: '支付宝', icon: 'alipay' },
  { id: 'union', name: '银联支付', icon: 'credit-card' },
  { id: 'balance', name: '余额支付', icon: 'wallet' },
] as const

// 商品标签颜色
export const TAG_COLORS = [
  '#ff4142', '#ff8800', '#00d100', '#4dabf7', 
  '#845ec2', '#f39c12', '#e74c3c', '#2ecc71'
] as const

// 本地存储键名
export const STORAGE_KEYS = {
  USER_INFO: 'mall_user_info',
  ACCESS_TOKEN: 'mall_access_token',
  REFRESH_TOKEN: 'mall_refresh_token',
  CART_DATA: 'mall_cart_data',
  SEARCH_HISTORY: 'mall_search_history',
  VIEWED_PRODUCTS: 'mall_viewed_products',
  SELECTED_ADDRESS: 'mall_selected_address',
  THEME_CONFIG: 'mall_theme_config',
} as const

// 错误代码映射
export const ERROR_CODE_MAP: Record<number, string> = {
  400: '请求参数错误',
  401: '未登录或登录已过期',
  403: '没有权限访问',
  404: '请求的资源不存在',
  500: '服务器内部错误',
  1001: '用户名或密码错误',
  1002: '用户不存在',
  1003: '用户已被禁用',
  2001: '商品不存在',
  2002: '商品库存不足',
  2003: '商品已下架',
  3001: '购物车为空',
  3002: '购物车商品已失效',
  4001: '订单不存在',
  4002: '订单状态异常',
  4003: '订单无法取消',
  5001: '优惠券不存在',
  5002: '优惠券已过期',
  5003: '优惠券使用条件不满足',
} as const

// 正则表达式
export const REGEX = {
  PHONE: /^1[3-9]\d{9}$/,
  EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
  PASSWORD: /^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d@$!%*?&]{6,20}$/,
  POSTAL_CODE: /^\d{6}$/,
  ID_CARD: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
} as const

// 时间格式
export const DATE_FORMATS = {
  DATE: 'YYYY-MM-DD',
  DATETIME: 'YYYY-MM-DD HH:mm:ss',
  TIME: 'HH:mm:ss',
  MONTH: 'YYYY-MM',
  YEAR: 'YYYY',
} as const